package entities;


import java.sql.Timestamp;
import java.util.Date;
import java.util.HashSet;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.PreUpdate;
import javax.persistence.Table;
import javax.persistence.Temporal;


@Entity
@Table(name="T_CUSTOMER")
public class Customer implements java.io.Serializable {

	private static final long serialVersionUID = 1L;

	private int customerId;
	private String firstName;
	private String lastName;
	private String street;
	private String postCode;
	private String city;
	private String phone;
	private String email;
	private String nip;
	private Date creationDate;
	private Date modificationDate;
	private Set<Invoice> invoices = new HashSet<>(0);
	private Set<Reservation> reservations = new HashSet<>(0);
	private Set<RetailOrder> retailOrders = new HashSet<>(0);
        private Set<Car> car = new HashSet<>(0);

	public Customer() {
	}

	public Customer(String firstName, String lastName, String street,
			String postCode, String city, String phone,
			Timestamp creationDate){
		this.firstName = firstName;
		this.lastName = lastName;
		this.street = street;
		this.postCode = postCode;
		this.city = city;
		this.phone = phone;
		this.creationDate = creationDate;
	}
	
	public Customer(String firstName, String lastName, String phone, Timestamp creationDate){
		this.firstName = firstName;
		this.lastName = lastName;
		this.phone = phone;
		this.creationDate = creationDate;
	}
	
	
	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)
	@Column(name="CUSTOMER_ID",unique = true, nullable = false)
	public int getCustomerId() {
		return this.customerId;
	}

	public void setCustomerId(int customerId) {
		this.customerId = customerId;
	}

	@Column(name="FIRST_NAME", nullable=false)
	public String getFirstName() {
		return this.firstName;
	}

	public void setFirstName(String firstName) {
		this.firstName = firstName;
	}
	
	@Column(name="LAST_NAME", nullable=false)
	public String getLastName() {
		return this.lastName;
	}

	public void setLastName(String lastName) {
		this.lastName = lastName;
	}

	@Column(name="STREET", nullable=true)
	public String getStreet() {
		return this.street;
	}

	public void setStreet(String street) {
		this.street = street;
	}

	@Column(name="POST_CODE", nullable=true)
	public String getPostCode() {
		return this.postCode;
	}

	public void setPostCode(String postCode) {
		this.postCode = postCode;
	}

	@Column(name="CITY", nullable=true)
	public String getCity() {
		return this.city;
	}

	public void setCity(String city) {
		this.city = city;
	}

	@Column(name="PHONE", nullable=true)
	public String getPhone() {
		return this.phone;
	}

	public void setPhone(String phone) {
		this.phone = phone;
	}

	@Column(name="EMAIL", nullable=true)
	public String getEmail() {
		return this.email;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	@Column(name="NIP", nullable=true)
	public String getNip() {
		return this.nip;
	}

	public void setNip(String nip) {
		this.nip = nip;
	}

	@Column(name="CREATION_DATE", nullable=false)
        @Temporal(javax.persistence.TemporalType.TIMESTAMP)
	public Date getCreationDate() {
		return this.creationDate;
	}

	public void setCreationDate(Date creationDate) {
		this.creationDate = creationDate;
	}

	@Column(name="MODIFICATION_DATE", nullable=true)
        @Temporal(javax.persistence.TemporalType.TIMESTAMP)
	public Date getModificationDate() {
		return this.modificationDate;
	}
	@PreUpdate
	public void setModificationDate(Date modificationDate) {
		this.modificationDate = modificationDate;
	}

	@OneToMany(fetch = FetchType.LAZY, mappedBy = "customer", cascade = CascadeType.ALL)
	public Set<Car> getCars() {
		return this.car;
	}

	public void setCars(Set<Car> car) {
		this.car = car;
	}
	
	@OneToMany(fetch = FetchType.LAZY, mappedBy = "customer", cascade = CascadeType.ALL)
	public Set<Reservation> getReservations() {
		return reservations;
	}

	public void setReservations(Set<Reservation> reservations) {
		this.reservations = reservations;
	}

	@OneToMany(fetch = FetchType.LAZY, mappedBy = "customer", cascade = CascadeType.ALL)
	public Set<RetailOrder> getRetailOrders() {
		return retailOrders;
	}

	public void setRetailOrders(Set<RetailOrder> retailOrders) {
		this.retailOrders = retailOrders;
	}

	@OneToMany(fetch = FetchType.LAZY, mappedBy = "customer", cascade = CascadeType.ALL)
	public Set<Invoice> getInvoices() {
		return invoices;
	}

	public void setInvoices(Set<Invoice> invoices) {
		this.invoices = invoices;
	}
	
	
	
	
}
